{% extends "skia_telemetry_base.html" %}

{% block content %}

<center>
{% if info_msg %}<font color="red"><b>{{ info_msg }}</b></font><br/><br/>{% endif %}
<h2>Add a new Chromium Build</h2>
<br/>

{% if not is_google_chromium_user %}
  Must have a google or chromium account to add new chromium buids (contact rmistry@)<br/><br/>
{% else %}
  <form name="chromiumBuildForm" action="chromium_builds" method="post">
    <table>
      <tr>
        <td>
          Chromium Commit Hash:
        </td>
        <td>
          <input type="text" name="chromium_rev" size="35" value="LKGR">
        </td>
      </tr>
      <tr>
        <td>
          Skia Commit Hash:
        </td>
        <td>
          <input type="text" name="skia_rev" size="35" value="LKGR">
        </td>
      </tr>
    </table>
    <br/>
    <input type="submit" value="Add">
    <br/>
  </form>
{% endif %}

<hr/>

  <h2>Repository of Chromium Builds</h2>
  <br/>

  {% if chromium_builds %}
  <table border="1" cellpadding="5">
    <tr bgcolor="#CCCCFF">
      <td><b>Chromium Commit Hash</b></td>
      <td><b>Submitted On</b></td>
      <td><b>Skia Commit Hash</b></td>
      <td><b>Requested Time</b></td>
      <td><b>Completed Time</b></td>
      <td><b>Build Log</b></td>
      <td><b>Delete</b></td>
    </tr>
    {% for build in chromium_builds %}
    <tr {% if not build.completed_time %}bgcolor="#8FDF5F"{% endif %} >
      <td align="center">
        <a href='https://chromium.googlesource.com/chromium/src/+/{{ build.chromium_rev }}'>{{ build.chromium_rev|slice:":7" }}</a>
      </td>
      <td align="center">
        {% if build.chromium_rev_date %}
          {{ build.chromium_rev_date }}
        {% else %}
          Calculating
        {% endif %}
      </td>
      <td align="center">
        <a href='https://skia.googlesource.com/skia/+/{{ build.skia_rev }}'>{{ build.skia_rev|slice:":7" }}</a>
      </td>
      <td align="center">
        {{ build.requested_time }}
      </td>
      <td align="center">
        {% if build.completed_time %}
          {{ build.completed_time }}
        {% else %}
          {% ifequal build.key.id_or_name oldest_pending_task_key %}
            In Progress
          {% else %}
            Waiting in Queue
          {% endifequal %}
        {% endif %}
      </td>
      <td align="center">
        {% if build.build_log_link %}
          <a href='{{ build.build_log_link }}' target='_blank'>log</a>
        {% else %}
          {% ifequal build.key.id_or_name oldest_pending_task_key %}
            In Progress
          {% else %}
            Waiting in Queue
          {% endifequal %}
        {% endif %}
      </td>
      <td align="center">
        <form action="chromium_builds" name="delete_chromium_build" method="post">
          <input type='hidden' name='delete' value='{{ build.key.id_or_name }}'>
          <input type='submit' value='Delete' {% if not is_google_chromium_user %}disabled{% endif %} {% ifequal build.key.id_or_name oldest_pending_task_key %}disabled{% endifequal %}>
        </form>
      </td>
    </tr>
    {% endfor %}
  </table>
  {% else %}
    No Chromium builds in the repository yet.
  {% endif %}
  <br/>
</center>

{% endblock %}
